package org.wkg.lesson11;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class Demo_1109 {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(10);
        System.out.println("开始比赛");
        for (int i = 0; i <10; i++) {
            Thread thread = new Thread(() -> {
                try {
                    System.out.println(Thread.currentThread().getName() + " 开跑");
                    TimeUnit.SECONDS.sleep(1);
                    System.out.println(Thread.currentThread().getName() + " 结束");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                countDownLatch.countDown();
            });
            thread.start();
        }
        TimeUnit.SECONDS.sleep(1);
        System.out.println("比赛进行中ing");
        countDownLatch.await();
        System.out.println("比赛结束");


    }
}
